from django.db import models
from django.contrib.auth.models import User
from osmp.host.models import Product, Host

# Create your models here.

class Flow(models.Model):
    tname = models.CharField(max_length=255)
    pid = models.ForeignKey(Product)
    hid = models.TextField()
    detail = models.TextField()
    attach = models.CharField(max_length=255, blank=True)
    send_uid = models.CharField(max_length=255)
    auth_uid = models.CharField(max_length=255)
    op_uid =  models.CharField(max_length=255)
    status = models.CharField(max_length=20)
    timestamp = models.DateTimeField(auto_now_add = True)

    def __unicode__(self):
        return "%s" % self.tname

    def __str__(self):
        return "%s" % self.tname
    
class FlowAction(models.Model):
    fid = models.ForeignKey(Flow)
    uid = models.ForeignKey(User)
    event = models.CharField(max_length=20)
    detail = models.TextField(blank=True)
    timestamp = models.DateTimeField(auto_now_add = True)
    
    def __unicode__(self):
        return "%s" % self.fid

    def __str__(self):
        return "%s" % self.fid
